// 测试Git MCP服务
const { exec } = require('child_process');
const { promisify } = require('util');

const execAsync = promisify(exec);

async function testGitMCP() {
  console.log('=== Git MCP 服务测试 ===\n');
  
  try {
    // 测试Git状态
    console.log('1. 测试Git状态...');
    const { stdout: status } = await execAsync('git status --porcelain');
    const { stdout: branch } = await execAsync('git branch --show-current');
    console.log(`当前分支: ${branch.trim()}`);
    console.log(`Git状态: ${status || '工作目录干净'}\n`);
    
    // 测试Git日志
    console.log('2. 测试Git日志...');
    const { stdout: log } = await execAsync('git log --oneline -n 5');
    console.log('最近5次提交:');
    console.log(log);
    
    // 测试Git分支
    console.log('3. 测试Git分支...');
    const { stdout: branches } = await execAsync('git branch -a');
    console.log('所有分支:');
    console.log(branches);
    
    console.log('\n✅ Git MCP服务测试完成！');
    console.log('Git MCP服务已准备就绪，可以集成到Cursor中。');
    
  } catch (error) {
    console.error('❌ 测试失败:', error.message);
  }
}

testGitMCP();

